package com.xju.atpgs.entity;

import java.text.DecimalFormat;
import java.util.List;

public class ExamQuestion {
    private List<Question> choice;
    private List<Question> judge;
    private List<Question> filling;
    private List<Question> shortAnswer;
    private List<Question> solve;
    private int choiceScore;
    private int judgeScore;
    private int fillingScore;
    private int shortAnswerScore;
    private int solveScore;
    private String difficulty;
    private int totalScore;

    public String getDifficulty() {
        return difficulty;
    }

    public void setDifficulty(String difficulty) {
        this.difficulty = difficulty;
    }

    public String getTotalScore() {
        return String.valueOf(totalScore);
    }

    public void setTotalScore(int totalScore) {
        this.totalScore = totalScore;
    }

    public int totalScore(){
        return choiceScore*choice.size()+judgeScore*judge.size()+fillingScore*filling.size()+shortAnswerScore*shortAnswer.size()+solveScore*solve.size();
    }

    public String difficulty(){
        double difficulty=0;
        for (Question choice:choice){
            difficulty+=Double.parseDouble(choice.getQuesLevel())*choiceScore;
        }
        for (Question judge:judge){
            difficulty+=Double.parseDouble(judge.getQuesLevel())*judgeScore;
        }
        for (Question filling:filling){
            difficulty+=Double.parseDouble(filling.getQuesLevel())*fillingScore;
        }
        for (Question shortAnswer:shortAnswer){
            difficulty+=Double.parseDouble(shortAnswer.getQuesLevel())*shortAnswerScore;
        }
        for (Question solve:solve){
            difficulty+=Double.parseDouble(solve.getQuesLevel())*solveScore;
        }
        int totalScore=totalScore();
        difficulty=difficulty/totalScore;
        DecimalFormat decimalFormat=new DecimalFormat("#0.00");
        return decimalFormat.format(difficulty);
    }

    public ExamQuestion(List<Question> choice, List<Question> judge, List<Question> filling, List<Question> shortAnswer, List<Question> solve, int choiceScore, int judgeScore, int fillingScore, int shortAnswerScore, int solveScore) {
        this.choice = choice;
        this.judge = judge;
        this.filling = filling;
        this.shortAnswer = shortAnswer;
        this.solve = solve;
        this.choiceScore = choiceScore;
        this.judgeScore = judgeScore;
        this.fillingScore = fillingScore;
        this.shortAnswerScore = shortAnswerScore;
        this.solveScore = solveScore;
        this.difficulty=difficulty();
        this.totalScore=totalScore();
    }

    public List<Question> getChoice() {
        return choice;
    }

    public void setChoice(List<Question> choice) {
        this.choice = choice;
    }

    public List<Question> getJudge() {
        return judge;
    }

    public void setJudge(List<Question> judge) {
        this.judge = judge;
    }

    public List<Question> getFilling() {
        return filling;
    }

    public void setFilling(List<Question> filling) {
        this.filling = filling;
    }

    public List<Question> getShortAnswer() {
        return shortAnswer;
    }

    public void setShortAnswer(List<Question> shortAnswer) {
        this.shortAnswer = shortAnswer;
    }

    public List<Question> getSolve() {
        return solve;
    }

    public void setSolve(List<Question> solve) {
        this.solve = solve;
    }

    public int getChoiceScore() {
        return choiceScore;
    }

    public void setChoiceScore(int choiceScore) {
        this.choiceScore = choiceScore;
    }

    public int getJudgeScore() {
        return judgeScore;
    }

    public void setJudgeScore(int judgeScore) {
        this.judgeScore = judgeScore;
    }

    public int getFillingScore() {
        return fillingScore;
    }

    public void setFillingScore(int fillingScore) {
        this.fillingScore = fillingScore;
    }

    public int getShortAnswerScore() {
        return shortAnswerScore;
    }

    public void setShortAnswerScore(int shortAnswerScore) {
        this.shortAnswerScore = shortAnswerScore;
    }

    public int getSolveScore() {
        return solveScore;
    }

    public void setSolveScore(int solveScore) {
        this.solveScore = solveScore;
    }
}
